package com.printer.printerexample;

import android.content.Context;

import com.rsk.printerlibrary.PrinterManager;
import com.rsk.printerlibrary.common.Printer_Params;

import java.util.Locale;

public class PrintStrUtils {


    public static boolean isZh(Context context) {
        Locale locale=context.getResources ().getConfiguration ().locale;
        String language=locale.getLanguage ();
        if (language.endsWith ("zh"))
            return true;
        else
            return false;
    }


    public static String LanguageChange(Context context) {
        String str="";
        if (!isZh (context)) {
            str=textEnContent ();
        } else {
            str=textZhContent ();
        }
        return str;
    }

    public static String textEnContent() {
        StringBuilder sb=new StringBuilder ();

        sb.append ("  The credentials of cashier      ");
        sb.append ("\n");
        sb.append ("Time   : ");
        sb.append ("2016-11-15     16:00");
        sb.append ("\n");
        sb.append ("The operator:admin");
        sb.append ("\n");
        sb.append ("The receipt number：1234567890");
        sb.append ("\n");
        sb.append ("Number  Quantity  Price  Discount  Subtotal");
        sb.append ("\n");
        sb.append ("-----------------------------");
        sb.append ("\n");
        sb.append ("AM126   1  1200  0   1200");
        sb.append ("\n");
        sb.append ("AM127   1  1300  0   1300");
        sb.append ("\n");
        sb.append ("AM128   1  1400  0   1400");
        sb.append ("\n");

        sb.append ("-----------------------------");
        sb.append ("\n");
        sb.append ("Total sales: 3 ");
        sb.append ("\n");
        sb.append ("Total(RMB): 3900");
        sb.append ("\n");
        sb.append ("Actual amount(RMB): 3900");
        sb.append ("\n");
        sb.append ("Change(RMB): 0");
        sb.append ("\n");

        sb.append ("\n");
        sb.append ("Mode of payment: WeChat Pay ");
        sb.append ("\n");
        sb.append ("Welcome to come again！");
        sb.append ("\n");
        sb.append ("Please keep the receipt.");
        sb.append ("\n");
        sb.append ("\n");
        sb.append ("\n");
        return sb.toString ();
    }

    public static String textZhContent() {
        StringBuilder sb=new StringBuilder ();

        sb.append ("        收 银 凭 据            ");
        sb.append ("\n");
        sb.append ("时间   : ");
        sb.append ("2016-11-15     16:00");
        sb.append ("\n");
        sb.append ("操作员:admin");
        sb.append ("\n");
        sb.append ("收据单号：1234567890");
        sb.append ("\n");
        sb.append ("编号  数量  单价  折扣  小计");

        sb.append ("\n");
        sb.append ("-----------------------------");
        sb.append ("\n");
        sb.append ("AM126   1  1200  0   1200");
        sb.append ("\n");
        sb.append ("AM127   1  1300  0   1300");
        sb.append ("\n");
        sb.append ("AM128   1  1400  0   1400");
        sb.append ("\n");

        sb.append ("-----------------------------");
        sb.append ("\n");
        sb.append ("共销售数量: 3 ");
        sb.append ("\n");
        sb.append ("售价合计(RMB): 3900");
        sb.append ("\n");
        sb.append ("实收金额(RMB): 3900");
        sb.append ("\n");
        sb.append ("找零金额(RMB): 0");
        sb.append ("\n");

        sb.append ("\n");
        sb.append ("付款方式：微信支付");
        sb.append ("\n");
        sb.append ("欢迎再次光临！");
        sb.append ("\n");
        sb.append ("请保留收据。");
        sb.append ("\n");
        sb.append ("\n");
        sb.append ("\n");
        return sb.toString ();
    }

    //英文打印
    public static void testEn() {
        PrinterManager mManager = PrinterUtils.getManager();
        mManager.PrintInit();
//        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.img);
//        mManager.PrintBitmap(bitmap);
        mManager.PrintLines(1);
        mManager.PrintChars("*KFC(shenzhen)*\n\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_WIDTH_DOUBLE);
        mManager.PrintChars("--pay success--\n\n");
        mManager.PrintInit();
        mManager.PrintChars("------------------------------\n");
//        mManager.PrintChars("期望送达时间： 立即送餐\n");
        mManager.PrintChars("OrderTime： 2020/06/13 09:33:25\r\n");
        mManager.PrintChars("OrderNo：   86962043527651331\r\n");
        mManager.PrintChars("-----------No. 1 shopping bag------------\r\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_DOUBLE);
        mManager.PrintChars("Italian           x1   $30.00\r\n");
        mManager.PrintChars("CocaCola          x1   $5.00\r\n");
        mManager.PrintInit();
        mManager.PrintChars("------------------------------\r\n");
        mManager.PrintChars("[Italian       discounts $10]\r\n");
        mManager.PrintChars("[fee reductions         $2.0]\r\n\n");
//        mManager.PrintChars("[门店新客吐血巨赠]\n\n");
        mManager.PrintChars("Gift：        the movie card\n\n");
        mManager.PrintChars("Delivery fee：       $0.00\r\n");
        mManager.PrintChars("Packaging fee：      $1.00\r\n");
        mManager.PrintChars("Price：              $36.00\r\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_WIDTH_DOUBLE);
        mManager.PrintChars("payment： $26.0\r\n");
        mManager.PrintInit();
        mManager.PrintChars("------------------------------\n");
        mManager.SetTextPosition(Printer_Params.BAR_TEXT_POS.NONE);
        mManager.PrintCode128("12345678abc");
        mManager.PrintChars("Voucher number： 052864\n");
        mManager.PrintChars("Terminal number：83357208\n");
        mManager.PrintChars("Payment account：matsushitayuya\n\n");
        mManager.PrintChars("---------------------------\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_WIDTH_DOUBLE);
        mManager.PrintChars("No. XX, Building XX, XX Community\n");
        mManager.PrintChars("Mr Kant\n");
        mManager.PrintChars("12112112121\n");
        mManager.PrintChars("100****0000\n");
        mManager.PrintInit();
        mManager.PrintChars("---------------------------\n");
        mManager.PrintChars("Scan code to view Info.\n\n");
        mManager.PrintQRWidth(2);
        mManager.PrintSetLayout(Printer_Params.ALIGN.CENTER);
        mManager.PrintQR("hello");
        mManager.PrintInit();
        mManager.PrintChars("\n\n");
        mManager.PrintChars("--------------Finish--------------");
        mManager.PrintInit();
    }


    public static void test() {
        PrinterManager mManager = PrinterUtils.getManager();
        mManager.PrintInit();
//        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.eleme);
//        mManager.PrintBitmap(bitmap);
        mManager.PrintLines(1);
        mManager.PrintChars("*大宝黄焖鸡米饭（时代城店）*\n\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_WIDTH_DOUBLE);
        mManager.PrintChars("--已在线支付--\n\n");
        mManager.PrintInit();
        mManager.PrintChars("------------------------------\n");
        mManager.PrintChars("期望送达时间： 立即送餐\n");
        mManager.PrintChars("下单时间： 2020/06/13 09:33:25\r\n");
        mManager.PrintChars("订单编号： 86962043527651331\r\n");
        mManager.PrintChars("-----------1号口袋------------\r\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_DOUBLE);
        mManager.PrintChars("黄焖鸡米饭        x1   30.00\r\n");
        mManager.PrintChars("可口可乐          x1   5.00\r\n");
        mManager.PrintInit();
        mManager.PrintChars("------------------------------\r\n");
        mManager.PrintChars("[黄焖鸡米饭限时立减10元]\r\n");
        mManager.PrintChars("[减配送费2元]\r\n");
        mManager.PrintChars("[门店新客吐血巨赠]\n\n");
        mManager.PrintChars("赠品：        漫威十周年套盒限量版\n\n");
        mManager.PrintChars("配送费：      0.00元\r\n");
        mManager.PrintChars("包装费：      1.00元\r\n");
        mManager.PrintChars("原价：      36.00元\r\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_WIDTH_DOUBLE);
        mManager.PrintChars("实付：  26.00元\r\n");
        mManager.PrintInit();
        mManager.PrintChars("------------------------------\n");
        mManager.SetTextPosition(Printer_Params.BAR_TEXT_POS.NONE);
        mManager.PrintCode128("12345678abc");
        mManager.PrintChars("凭证号：052864\n");
        mManager.PrintChars("终端编号：83357208\n");
        mManager.PrintChars("买家账号：matsushitayuya\n\n");
        mManager.PrintChars("---------------------------\n");
        mManager.PrintFontMagnify(Printer_Params.TEXT_ENLARGE.HEIGHT_WIDTH_DOUBLE);
        mManager.PrintChars("XX街道XX小区XX栋XX号\n");
        mManager.PrintChars("赵（小姐）\n");
        mManager.PrintChars("12112112121\n");
        mManager.PrintChars("100****0000\n");
        mManager.PrintInit();
        mManager.PrintChars("---------------------------\n");
        mManager.PrintChars("扫二维码领取红包\n\n");
        mManager.PrintQRWidth(2);
        mManager.PrintSetLayout(Printer_Params.ALIGN.CENTER);
        mManager.PrintQR("5元");
        mManager.PrintInit();
        mManager.PrintChars("\n\n");
        mManager.PrintChars("--------------完--------------");
        mManager.PrintInit();
        mManager.PrintLines(4);
    }
    public static String ParkingFeeChinese() {
        StringBuilder sb = new StringBuilder();
        sb.append ("\n");
        sb.append ("-------------------------------\n");
        sb.append("收费单位：XXXXXX收费平台\n");
        sb.append("收费员：刘XX\n");
        sb.append("街道名称：锦江区梨花街XX号\n");
        sb.append("车位号：CL002\n");
        sb.append("车牌：川A123456\n");
        sb.append("驶入时间：2023-05-23 08:46:22\n");
        sb.append("驶离时间：2023-05-23 17:56:26\n");
        sb.append("停车时长：9小时10分钟04秒\n");
        sb.append ("-----------------------------\n");
        sb.append("            温馨提示            \n");
        sb.append(" 川A123456车主您好，您在2023-05-23 24:00:00 之前有累计3笔停车未付款记录，请尽快补缴相关费用\n");
        sb.append ("-----------------------------\n");
        return sb.toString();
    }
    public static String ParkingFeeChinese1() {
        StringBuilder sb = new StringBuilder();

        sb.append ("-----------------------------\n");
        sb.append("伴随智慧城市进程的推进,人们追求生活智能化.道路拥堵,交通堵塞以及停车难等城市交通问题让有车一族头疼不已,降低了人们的停车体验，成都市XXX收费平台引导车主用户合理有效地停车并快速反向寻车。\n");
        sb.append("服务咨询电话：028-6523316666\n");
        sb.append("价格投诉电话：12358\n");
        sb.append("温馨提示：若车主离开时未找到收费管理员，可自行驶离，系统将自动停止计费，自动计算入下次停车费用中。\n");
        return sb.toString();
    }


    public static String ParkingFeeEng() {
        StringBuilder sb = new StringBuilder();
        sb.append ("\n");
        sb.append ("--------------------------------\n");
        sb.append("Charging unit:XXXXXX Charging Platform\n");
        sb.append("Toll collector:Liu XX\n");
        sb.append("Street name:No.XX,Lihua Street,Jinjiang District\n");
        sb.append("Parking space number:CL002\n");
        sb.append("License plate:ChuanA123456\n");
        sb.append("Entry time:2023-05-23 08:46:22\n");
        sb.append("Departure time：2023-05-23 17:56:26\n");
        sb.append("Parking time: 9 hours, 10 minutes, and 04 seconds\n");
        sb.append ("--------------------------------\n");
        sb.append("            Kindly Tips          \n");
        sb.append(" Hello, car owner of Sichuan A123456. You have three cumulative records of unpaid parking before 24:00:00 on May 23, 2023. Please make up for the relevant fees as soon as possible\n");
        sb.append ("--------------------------------\n");
        return sb.toString();
    }
    public static String ParkingFeeEng1() {
        StringBuilder sb = new StringBuilder();

//        sb.append("Fee amount:54RMB\n");
        sb.append ("--------------------------------");
        sb.append("With the advancement of the smart city process, people are pursuing intelligent living. Urban traffic problems such as road congestion, traffic congestion, and parking difficulties are causing headaches for car owners, reducing their parking experience. The Chengdu XXX toll platform guides car owners and users to park reasonably and effectively, and quickly search for cars in reverse.\n");
        sb.append("Service hotline:028-652331666\n");
        sb.append("Complaint hotline:12358\n");
        sb.append("Kind reminder: If the owner does not find the toll administrator when leaving, they can drive and leave by themselves. The system will automatically stop billing and calculate it into the next parking fee.\n");
        return sb.toString();
    }

}
